Conversation
WalkthroughThis PR addresses a limitation where importing store files with more than 100 assertions would fail. The changes implement batching of assertion imports in groups of 100, precompute total assertion counts for efficient slice allocation, introduce comprehensive test coverage for batching behavior, and apply performance-oriented slice preallocation optimizations across test utilities. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Documentation Updates 1 document(s) were updated by changes in this PR: Contextual Tuples SupportView Changes@@ -26,6 +26,14 @@
For ABAC scenarios, an optional `context` object can be included to provide additional attribute data for condition evaluation.
There are limits on the number of contextual tuples: up to 100 per request (as of OpenFGA v1.7.0), and up to 20 per assertion in Write Assertions. Exceeding these limits will result in a request error. [Reference](https://github.com/openfga/openfga/blob/28ed51fb5f6c9e3eb113e15b8b98fb7eb1aa56aa/CHANGELOG.md#L287-L764)
+
+### CLI Import Behavior for Write Assertions
+
+When using the `fga store import` command, there is a limit of 100 assertions per write operation. If you attempt to import a store with more than 100 assertions, the CLI will:
+- Write only the first 100 assertions
+- Display a warning message: `Warning: N test assertions found, but only the first 100 will be written`
+
+This limit is enforced by the CLI tool's import functionality, not by the OpenFGA server API itself. If you need to import more than 100 assertions, you will need to make multiple separate write operations.
## Specifying Contextual Tuples in Requests
|
rhamzeh
left a comment
There was a problem hiding this comment.
This does not work as you'd expect - the API accepts a max of 100 assertions: https://github.com/openfga/api/blob/main/openfga/v1/openfga_service.proto#L1639-L1650
Every following WriteAssertions request will just override what came before it.
There was a problem hiding this comment.
Pull request overview
Addresses #618 by changing how store import writes test assertions to comply with the API limit of 100 assertions per WriteAssertions request.
Changes:
- Introduces a
maxAssertionsPerWritelimit (100) in the store import flow. - Updates assertion import error message text.
- Adds/updates tests around importing assertions with large volumes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/storetest/remotetest.go | Minor formatting change (blank line) in remote list-users test helper. |
| cmd/store/import.go | Adds max-assertions limit handling and tweaks error message for assertion import. |
| cmd/store/import_test.go | Refactors IDs into constants and adds a new test for >100 assertions behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
What problem is being solved?
Fixes #618
How is it being solved?
OpenFGA does not support storing more than 100 assertions.
When trying to import a store with
fga store import, if the file has more than 100 assertions, the whole import fails.What changes are made to solve it?
Only write the first 100 assertions and print a warning.
References
Review Checklist
mainSummary by CodeRabbit
New Features
Tests
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.